var menus = '';
// 编写正则验证
function validate() {
	var reg = new RegExp("^[1-9]*.$");
	return reg;
}
//评价实例
function GetDataEva(data, t) {
	var len = data.children.length;
	var RegVa = validate();
	if(len > 0) {
		menus += '<ul>';
		for(var i = 0; i < len; i++) {
			var t1 = t + (i + 1) + ".";
			var child = data.children[i];
			var class1 = "test_content_myhconttile";
			var class2 = "test_content_hcontt";
			var class3 = "test_content_nr_tt";
			var mymenus = "";
			if(child.children.length>0) {
				mymenus = '<li class='+class1+'><h3>' + t1 + ' ' + child.eTitle + '</h3>';
			} else {
				mymenus = '<li class='+class2+'><div class='+class3+'>' + t1 + ' ' + child.eTitle + '</div>';
			}
			if(RegVa.test(t1)){
				mymenus = '<li class='+class1+'><h3 class="test_content_myhconttile_color">' + t1 + ' ' + child.eTitle + '</h3>';
			}
			menus += mymenus;
			GetDataEva(child, t1);
			menus += '</li>';
		}
		menus += '</ul>';
	} else {
		var htmls = '<div class="test_content_nr_main"><ul>' +
			'<li class="option">' +
			'<input type="radio" class="radioOrCheck" name="' + data.eId + '" id="0_answer_' + data.eId + '_option_1" value="4"/>' +
			'<label for="0_answer_' + data.eId + '_option_1">' +
			'<p class="ue" style="display: inline;">非常满意</p>' +
			'</label>' +
			'</li>' +
			'<li class="option">' +
			'<input type="radio" class="radioOrCheck" name="' + data.eId + '" id="0_answer_' + data.eId + '_option_2" value="3"/>' +
			'<label for="0_answer_' + data.eId + '_option_2">' +
			'<p class="ue" style="display: inline;">满意</p>' +
			'</label>' +
			'</li>' +
			'<li class="option">' +
			'<input type="radio" class="radioOrCheck" name="' + data.eId + '" id="0_answer_' + data.eId + '_option_3" value="2"/>' +
			'<label for="0_answer_' + data.eId + '_option_3">' +
			'<p class="ue" style="display: inline;">一般</p>' +
			'</label>' +
			'</li>' +
			'<li class="option">' +
			'<input type="radio" class="radioOrCheck" name="' + data.eId + '" id="0_answer_' + data.eId + '_option_4" value="1"/>' +
			'<label for="0_answer_' + data.eId + '_option_4">' +
			'<p class="ue" style="display: inline;">较差</p>' +
			'</label>' +
			'</li>' +
			'</ul></div>';
		menus += htmls;
	}
}



//查看详情
function GetDataDetails(data, t) {
	var len = data.children.length;
	var RegVa = validate();
	if(len > 0) {
		menus += '<ul>';
		for(var i = 0; i < len; i++) {
			var t1 = t + (i + 1) + ".";
			var child = data.children[i];
			var class1 = "test_content_myhconttile";
			var class2 = "test_content_hover";
			var class3 = "test_content_nr_tt";
			var mymenus = "";
			if(child.children.length > 0) {
				mymenus = '<li class=' + class1 + '><h3>' + t1 + ' ' + child.eTitle + '</h3>';
			} else {
				mymenus = '<li class=' + class2 + '><div class=' + class3 + '>' + t1 + ' ' + child.eTitle + '<div class="test_content_nr_main_span" style="float:right;" data-id=' + child.eId + '><span class="mypinjia">我的评价: <span class="myfen"></span></span></div></div>';
			}
			if(RegVa.test(t1)) {
				mymenus = '<li class=' + class1 + '><h3 class="test_content_myhconttile_color">' + t1 + ' ' + child.eTitle + '</h3>';
			}
			menus += mymenus;
			GetDataDetails(child, t1);
			menus += '</li>';
		}
		menus += '</ul>';
	}
	//	menus += '<div class="test_content_nr_main_span" data-id=' + data.eId + '><span class="mypinjia">我的评价: <span class="myfen"></span></span></div>';
}
//查看详情一层数据
function GetDataOneBed(data, t) {
	var len = data.children.length;
	var RegVa = validate();
	if(len > 0) {
		menus += '<ul>';
		for(var i = 0; i < len; i++) {
			var t1 = t + (i + 1) + ".";
			var child = data.children[i];
			var class1 = "test_content_myhconttile";
			var class2 = "test_content_hover";
			var class3 = "test_content_nr_tt";
			var mymenus = "";
			if(child.children.length > 0) {
				mymenus = '<li class=' + class1 + '><h3>' + t1 + ' ' + child.eTitle + '</h3>';
			} else {
				mymenus = '<li class=' + class2 + '><div class=' + class3 + ' style="font-size:16px">' + t1 + ' ' + child.eTitle + '<div class="test_content_nr_main_span" style="float:right;" data-id=' + child.eId + '><span class="mypinjia">我的评价: <span class="myfen"></span></span></div></div>';
			}
//			if(RegVa.test(t1)) {
//				mymenus = '<li class=' + class1 + '><h3 class="test_content_myhconttile_color">' + t1 + ' ' + child.eTitle + '</h3>';
//			}
			menus += mymenus;
			GetDataOneBed(child, t1);
			menus += '</li>';
		}
		menus += '</ul>';
	}
	//	menus += '<div class="test_content_nr_main_span" data-id=' + data.eId + '><span class="mypinjia">我的评价: <span class="myfen"></span></span></div>';
}

//渲染评价
function addMyfenTeacher(data) {
	var translate = ["较差", "一般", "满意", "非常满意"];
	$.each(data.data, function(i, object) {
		$.each(JSON.parse(object.scoresT), function(n, m) {
			$('.test_content_nr_main_span[data-id=' + m.tId + ']').find(".myfen").html(translate[m.value - 1]);
		});
	});
	wordRender();
}
//渲染评价
function addMyfenStudent(data) {
	var translate = ["较差","一般","满意","非常满意"];
	$.each(data.data, function(i, object) {
		$.each(JSON.parse(object.scores), function(n, m) {
			$('.test_content_nr_main_span[data-id=' + m.tId + ']').find(".myfen").html(translate[m.value - 1]);
		});
	});
	wordRender();
}
//渲染评价(文字渲染)
function wordRender(){
	var translate = ["较差","一般","满意","非常满意"];
	$(".myfen").each(function() {
		if($(this).text() == translate[0]) {
			$(this).css("color", "red")
		}
		if($(this).text() == translate[1]) {
			$(this).css("color", "#FF7F00")
		}
		if($(this).text() == translate[2]) {
			$(this).css("color", "#9ACD32")
		}
		if($(this).text() == translate[3]) {
			$(this).css("color", "#00CD66")
		}
	})
}
